﻿// -----------------------------------------------------------------------
// <copyright file="AmazonHeader.cs" company="EPAM Systems">
////Copyright (c) EPAM Systems, 2012. All rights reserved.
// </copyright>
// -----------------------------------------------------------------------

namespace MBOP.DistributedServices.AmazonHeaders
{
	#region Usings

	using System.ServiceModel.Channels;
	using System.Xml;

	using MBOP.Configuration.ConfigElements;

	#endregion

	/// <summary>
	/// Represents the amazon message header.
	/// </summary>
	public class AmazonHeader : MessageHeader
	{
		#region Private Fields

		/// <summary>
		/// Represents the name of the header.
		/// </summary>
		private string _name;

		/// <summary>
		/// Represents the value of the header.
		/// </summary>
		private string _value;

		#endregion

		/// <summary>
		/// Initializes a new instance of the <see cref="AmazonHeader"/> class.
		/// </summary>
		/// <param name="name">The name of the header.</param>
		/// <param name="value">The value for the header.</param>
		public AmazonHeader(string name, string value)
		{
			this._name = name;
			this._value = value;
		}

		/// <summary>
		/// Gets the header name.
		/// </summary>
		public override string Name 
		{
			get 
			{
				return this._name; 
			}
		}

		/// <summary>
		/// Gets the namespace name.
		/// </summary>
		public override string Namespace 
		{
			get
			{
				return AppConfigurationSection.GetInstance().DistributedServices.AmazonService.SecurityNamespace; 
			}
		}

		/// <summary>
		/// Hooks the write header contents.
		/// </summary>
		/// <param name="xmlDictionaryWriter">The xml writer.</param>
		/// <param name="messageVersion">The message version.</param>
		protected override void OnWriteHeaderContents(XmlDictionaryWriter xmlDictionaryWriter, MessageVersion messageVersion)
		{
			xmlDictionaryWriter.WriteString(this._value);
		}
	}
}
